﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Net;
using System.IO;
using System.Xml;
using System.Text;
using System.Text.RegularExpressions;


namespace asMeishi.spider.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "欢迎使用 ASP.NET MVC!";

            return View();
        }
        public ActionResult dzdp(string url = "http://www.fantong.com/anshan-recommend/j9896n15g/", string idx = "1")
        {


            HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create(url + idx);
            
            hwr.Accept = "*/*";
            CookieContainer c = new CookieContainer();
            CookieCollection cc = new CookieCollection();
            
            cc.Add(new Cookie("city","鞍山"));
            cc.Add(new Cookie("stat_visitorid","5e439bd04c6daba1aad7a2351754f7d3"));
            cc.Add(new Cookie("webbooker", "xxx"));
            cc.Add(new Cookie("webbookerphone", "13312312311"));
            cc.Add(new Cookie("webbookersex", "1"));
            cc.Add(new Cookie("restaurant0", "20117431"));
            cc.Add(new Cookie("PHPSESSID", "b6be1e1a836e93ba87819ce07fc3"));
            cc.Add(new Cookie("sh0", "%E9%93%81%E4%B8%9C%E5%8C%BA"));
            cc.Add(new Cookie("CNZZDATA30054121", "=cnzz_eid=75064978-1348276125-http%253A%252F%252Fwww.baidu.com%252Fs%253Fwd%253D%2525E9%2525A5%2525AD%2525E7%2525BB%25259F%2525E7%2525BD%252591%2526ie%253DUTF-8%2526oe%253DUTF-8%2526bar%253D13%2526tn%253D22083068_cb&ntime=1352420810&cnzz_a=8&retime=1352420940463&sin=none&ltime=1352420940463&rtime=4"));

            c.Add(new Uri("http://www.fantong.com"), cc);
            hwr.CookieContainer=c;

            hwr.Timeout = 300000;
            hwr.ContentType = "application/x-www-form-urlencoded";
            hwr.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)";
            hwr.Referer = "http://www.fantong.com/anshan-recommend/j9896n15/";
            //hwr.Accept= "zh-CN";
            //hwr.Connection = "Keep-Alive";
            hwr.Host = "www.fantong.com";


            hwr.Method = "GET";
            HttpWebResponse hwres = (HttpWebResponse)hwr.GetResponse();

           // Stream myStream = hwres.GetResponseStream();

            using (StreamReader reader = new StreamReader(hwres.GetResponseStream(),Encoding.GetEncoding("utf-8")))
            {
                string xx = reader.ReadToEnd().Replace("\r\n", "").Replace("\t", "").Replace("\r", "").Replace("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">","");



            }
 



            



            return View();
        }

        public ActionResult About()
        {
            return View();
        }
    }
}
